<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AlterTableDormMetersAddExpireDate extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('dorm_meters', function (Blueprint $table) {
            if(!Schema::hasColumn('dorm_meters','expire_date')){
                $table->date('expire_date')->default('9999-12-31');
            }
            if(!Schema::hasColumn('dorm_meters','install_date')){
                $table->date('install_date')->nullable();
            }
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('dorm_meters', function (Blueprint $table) {
            $table->dropColumn('expire_date');
            $table->dropColumn('install_date');
        });
    }
}
